#include<bits/stdc++.h>
using namespace std;
//https://ac.nowcoder.com/acm/contest/5556/E 
const int N = 200010, mod = 1e9+7;
int T, n, m, k;
int a[N], l[N], r[N];
bitset<100*100*100+10> dp[110];

signed main(){
	cin>>n;
	
	for(int i=1;i<=n;i++) cin>>l[i]>>r[i];
	
	dp[0][0] = 1;
	for(int i=1;i<=n;i++)
	{
		for(int j=l[i];j<=r[i];j++)
		{
			dp[i] |= (dp[i-1]<<j*j);
		}
	}
	cout << dp[n].count();

	return 0;
}

